package main.java.proxy;

/**
 * 修改 SimpleProxyDemo,使其可以度量方法的调用次数
 */
public class Demo1 {
    private static int countDoSomeThing;
    private static int countSomethingElse;

    public static void consumer(Interface iface) {
        iface.doSomething();
        ++countDoSomeThing;
        iface.somethingElse("bonobo");
        ++countSomethingElse;

    }

    public static void main(String[] args) {
        consumer(new RealObject());
        consumer(new SimpleProxy(new RealObject()));

        System.out.println(" doSomething 执行次数:"+countDoSomeThing);
        System.out.println(" somethingElse 执行次数:"+countSomethingElse);

    }
}
